package com.zzyl.nursing.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzyl.nursing.domain.Floor;
import com.zzyl.nursing.mapper.FloorMapper;
import com.zzyl.nursing.service.IFloorService;
import com.zzyl.nursing.vo.FloorVo;
import com.zzyl.nursing.vo.TreeVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * 楼层Service业务层处理
 */
@Service
public class FloorServiceImpl extends ServiceImpl<FloorMapper, Floor> implements IFloorService {

    @Autowired
    private FloorMapper floorMapper;

    //查询楼层
    @Override
    public Floor selectFloorById(Long id) {
        return getById(id);
    }

    //新增楼层
    @Override
    public int insertFloor(Floor floor) {
        return save(floor) ? 1 : 0;
    }

    //修改楼层
    @Override
    public int updateFloor(Floor floor) {
        return updateById(floor) ? 1 : 0;
    }

    //批量删除楼层
    @Override
    public int deleteFloorByIds(Long[] ids) {
        return removeByIds(Arrays.asList(ids)) ? 1 : 0;
    }

    //根据状态查询楼层房间床位-树形结构
    @Override
    public List<TreeVo> getRoomAndBedByBedStatus(Integer status) {
        return floorMapper.getRoomAndBedByBedStatus(status);
    }

    //查询负责老人楼层
    @Override
    public List<Floor> selectAllByNur() {
        return floorMapper.selectAllByNur();
    }

    //查询智能楼层
    @Override
    public List<FloorVo> getAllFloorsWithDevice() {
        return floorMapper.getAllFloorsWithDevice();
    }
}